<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<style type="text/css"> 
.tab{ margin:0; padding:0; /*合并边线*/border-collapse:collapse;} 
.tab td{ border:solid 1px #000} 
</style> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>

		<title>payAssist测试</title>
	</head>

	<body>
		<table class="table" width="100%">
			<tr>
				<td align="center" colspan="8">与客户端接口</td>
			</tr>
			<tr>
				<td align="center" colspan="4"><a href="javascript:void(0)"  onClick="call('cheakPayAssis');">查询交费助手状况(cheakPayAssis)</a></td>
				<td align="center" colspan="4"><a href="javascript:void(0)"  onClick="call('openPayAssis');">开通交费助手(openPayAssis)</a></td></tr>
	</table>
		请求参数：
			<span>PRODUCTNO:</span><input  id="PRODUCTNO"/></br>
			<span>SESSIONKEY:</span><input  id="SESSIONKEY" value="1"/></br>
			<span>VERSION:</span><input  id="VERSION" value="1" /></br>
			<span id="url">url:</span></br>
		<div id="cheakPayAssis" style="display: none;">
		</div>
		<div id="isOpenCreditPayment" style="display: none;">
		</div>
        <div id="queryPayMassage" style="display: none;">
        </div>
        <div id="queryCreditPaymentRecords" style="display: none;">
        </div>
        
        <div id="isOpenWhiteBar" style="display: none;">
			<span>ACCEPTUSER</span><input  id="ACCEPTUSER"/></br>
		</div>
		 <div id="agreementOpen" style="display: none;">
			<span>ACCEPTUSER</span><input  id="ACCEPTUSER"/></br>
		</div>
		 <div id="closeAgreement" style="display: none;">
			<span>ACCEPTUSER</span><input  id="ACCEPTUSER"/></br>
		</div>
		返回json：</br><textarea rows="5" cols="120"  id="responseTest"></textarea>
		<button onclick="sub();" style="display: none" id="sub">提交</button>
	</body>
</html>
<script type="text/javascript">
var divId = "";
function call(str){
	divId = str;
	var divs =document.getElementsByTagName("div");
	for(var   i=0;i<divs.length;i++ ){
		divs[i].style.display = 'none';
	}
	document.getElementById(str).style.display = 'block';
	document.getElementById("responseTest").value = '';
	document.getElementById("sub").style.display = 'block';
	
}
function sub(){
	var inputs =document.getElementById(divId).getElementsByTagName("input");
	var url = "/freeapp/"+divId+"?PRODUCTNO="+document.getElementById("PRODUCTNO").value;
	for(var   i=0;i<inputs.length;i++ ){
			var url = url+ inputs[i].id+"="+inputs[i].value+"&";
	}
	//url +="</a>";
	//window.open(url);
	sendAjaxRequest(url);
	 var myelement= document.createElement("a");
	 myelement.href=url;
	 myelement.setAttribute("target","_black");
	 myelement.innerText=url;
	 document.getElementById("url").removeChild(document.getElementById("url").firstChild);
	 document.getElementById("url").appendChild(myelement);
}
var XMLHttpReq;
function createXMLHttpRequest() {
    try {
        XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");//IE高版本创建XMLHTTP
    }
    catch(E) {
        try {
            XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");//IE低版本创建XMLHTTP
        }
        catch(E) {
            XMLHttpReq = new XMLHttpRequest();//兼容非IE浏览器，直接创建XMLHTTP对象
        }
    }

}
function sendAjaxRequest(url) {
    createXMLHttpRequest();                                //创建XMLHttpRequest对象
    XMLHttpReq.open("post", url, true);
    XMLHttpReq.onreadystatechange = processResponse; //指定响应函数
    XMLHttpReq.send(null);
}
//回调函数
function processResponse() {
    if (XMLHttpReq.readyState == 4) {
        if (XMLHttpReq.status == 200) {
            var text = XMLHttpReq.responseText;
            /**
             *实现回调
             */
            text = window.decodeURI(text);
            var cp = document.getElementById("responseTest");
            cp.value = text;
        }
    }

}

</script>